<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="zh">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=11"/>
<meta name="generator" content="Doxygen 1.11.0"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>cppMISC: include/container/skipList.hpp 源文件</title>
<link href="../../tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="../../jquery.js"></script>
<script type="text/javascript" src="../../dynsections.js"></script>
<script type="text/javascript" src="../../clipboard.js"></script>
<link href="../../navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="../../resize.js"></script>
<script type="text/javascript" src="../../cookie.js"></script>
<link href="../../search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="../../search/searchdata.js"></script>
<script type="text/javascript" src="../../search/search.js"></script>
<script type="text/javascript" src="../../darkmode_toggle.js"></script>
<link href="../../doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr id="projectrow">
  <td id="projectalign">
   <div id="projectname">cppMISC<span id="projectnumber">&#160;v1.1</span>
   </div>
   <div id="projectbrief">cppMisc 文档系统</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- 制作者 Doxygen 1.11.0 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
var searchBox = new SearchBox("searchBox", "../../search/",'.html');
/* @license-end */
</script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(function() { codefold.init(1); });
/* @license-end */
</script>
<script type="text/javascript" src="../../menudata.js"></script>
<script type="text/javascript" src="../../menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(function() {
  initMenu('../../',true,false,'search.php','搜索',false);
  $(function() { init_search(); });
});
/* @license-end */
</script>
<div id="main-nav"></div>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(function(){ initResizable(false); });
/* @license-end */
</script>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<div id="MSearchResults">
<div class="SRPage">
<div id="SRIndex">
<div id="SRResults"></div>
<div class="SRStatus" id="Loading">载入中...</div>
<div class="SRStatus" id="Searching">搜索中...</div>
<div class="SRStatus" id="NoMatches">未找到</div>
</div>
</div>
</div>
</div>

<div id="nav-path" class="navpath">
  <ul>
<li class="navelem"><a class="el" href="../../dir_d44c64559bbebec7f509842c48db8b23.html">include</a></li><li class="navelem"><a class="el" href="../../dir_e0f5f6345e438c73b9ae78ec2940718c.html">container</a></li>  </ul>
</div>
</div><!-- top -->
<div id="doc-content">
<div class="header">
  <div class="headertitle"><div class="title">skipList.hpp</div></div>
</div><!--header-->
<div class="contents">
<a href="../../d7/de1/skip_list_8hpp.html">浏览该文件的文档.</a><div class="fragment"><div class="line"><a id="l00001" name="l00001"></a><span class="lineno">    1</span> </div>
<div class="line"><a id="l00008" name="l00008"></a><span class="lineno">    8</span><span class="preprocessor">#pragma once</span></div>
<div class="line"><a id="l00009" name="l00009"></a><span class="lineno">    9</span> </div>
<div class="line"><a id="l00010" name="l00010"></a><span class="lineno">   10</span><span class="preprocessor">#include &lt;list&gt;</span></div>
<div class="line"><a id="l00011" name="l00011"></a><span class="lineno">   11</span><span class="preprocessor">#include &lt;type_traits&gt;</span></div>
<div class="line"><a id="l00012" name="l00012"></a><span class="lineno">   12</span><span class="preprocessor">#include &lt;vector&gt;</span></div>
<div class="line"><a id="l00013" name="l00013"></a><span class="lineno">   13</span><span class="preprocessor">#inlucde &lt;memory&gt;</span></div>
<div class="line"><a id="l00014" name="l00014"></a><span class="lineno">   14</span><span class="preprocessor">#include &lt;mutex&gt;</span></div>
<div class="line"><a id="l00015" name="l00015"></a><span class="lineno">   15</span> </div>
<div class="line"><a id="l00016" name="l00016"></a><span class="lineno">   16</span><span class="keyword">template</span>&lt; <span class="keyword">typename</span> T &gt;</div>
<div class="foldopen" id="foldopen00017" data-start="{" data-end="};">
<div class="line"><a id="l00017" name="l00017"></a><span class="lineno"><a class="line" href="../../d7/d37/classskip_list.html">   17</a></span><span class="keyword">class </span><a class="code hl_class" href="../../d7/d37/classskip_list.html">skipList</a></div>
<div class="line"><a id="l00018" name="l00018"></a><span class="lineno">   18</span>{</div>
<div class="line"><a id="l00019" name="l00019"></a><span class="lineno">   19</span><span class="keyword">public</span>:</div>
<div class="line"><a id="l00020" name="l00020"></a><span class="lineno"><a class="line" href="../../d7/d37/classskip_list.html#ab04a8617aa95c59b6823c4a7f90c4d60">   20</a></span>    <span class="keyword">using </span><a class="code hl_typedef" href="../../d7/d37/classskip_list.html#ab04a8617aa95c59b6823c4a7f90c4d60">value_type</a> = <span class="keyword">typename</span> std::remove_pointer&lt; typename std::decay&lt; T &gt; ::type &gt;::type;</div>
<div class="line"><a id="l00021" name="l00021"></a><span class="lineno">   21</span> </div>
<div class="foldopen" id="foldopen00022" data-start="{" data-end="};">
<div class="line"><a id="l00022" name="l00022"></a><span class="lineno"><a class="line" href="../../d6/d1d/structskip_list_1_1st_node.html">   22</a></span>    <span class="keyword">struct </span><a class="code hl_struct" href="../../d6/d1d/structskip_list_1_1st_node.html">stNode</a>{</div>
<div class="line"><a id="l00023" name="l00023"></a><span class="lineno"><a class="line" href="../../d6/d1d/structskip_list_1_1st_node.html#aeab4d54bbcfd42dcf9797573f280d2c0">   23</a></span>        <a class="code hl_typedef" href="../../d7/d37/classskip_list.html#ab04a8617aa95c59b6823c4a7f90c4d60">value_type</a>     <a class="code hl_variable" href="../../d6/d1d/structskip_list_1_1st_node.html#aeab4d54bbcfd42dcf9797573f280d2c0">m_value</a>;</div>
<div class="line"><a id="l00024" name="l00024"></a><span class="lineno"><a class="line" href="../../d6/d1d/structskip_list_1_1st_node.html#ad026941f387c6246bb4d2839199d8f7b">   24</a></span>        std::shared_ptr&lt; stNode &gt;     <a class="code hl_variable" href="../../d6/d1d/structskip_list_1_1st_node.html#ad026941f387c6246bb4d2839199d8f7b">pt_next</a>;     <span class="comment">// 后继节点</span></div>
<div class="line"><a id="l00025" name="l00025"></a><span class="lineno"><a class="line" href="../../d6/d1d/structskip_list_1_1st_node.html#a2541341e5aaeed692acae459554700f9">   25</a></span>        std::shared_ptr&lt; stNode &gt;     <a class="code hl_variable" href="../../d6/d1d/structskip_list_1_1st_node.html#a2541341e5aaeed692acae459554700f9">pt_pre</a>;      <span class="comment">// 前驱节点</span></div>
<div class="line"><a id="l00026" name="l00026"></a><span class="lineno"><a class="line" href="../../d6/d1d/structskip_list_1_1st_node.html#a26cc314106ff74169938ed021c555fe1">   26</a></span>        std::shared_ptr&lt; stNode &gt;     <a class="code hl_variable" href="../../d6/d1d/structskip_list_1_1st_node.html#a26cc314106ff74169938ed021c555fe1">pt_down</a>;     <span class="comment">// 下行节点</span></div>
<div class="line"><a id="l00027" name="l00027"></a><span class="lineno">   27</span>    };</div>
</div>
<div class="line"><a id="l00028" name="l00028"></a><span class="lineno">   28</span>    </div>
<div class="foldopen" id="foldopen00029" data-start="{" data-end="};">
<div class="line"><a id="l00029" name="l00029"></a><span class="lineno"><a class="line" href="../../de/d7b/structskip_list_1_1st_head.html">   29</a></span>    <span class="keyword">struct </span><a class="code hl_struct" href="../../de/d7b/structskip_list_1_1st_head.html">stHead</a>{</div>
<div class="line"><a id="l00030" name="l00030"></a><span class="lineno"><a class="line" href="../../de/d7b/structskip_list_1_1st_head.html#ac6d06c75ea6ae12bcab635e1a2b8b7c1">   30</a></span>        <span class="keywordtype">size_t</span>                        <a class="code hl_variable" href="../../de/d7b/structskip_list_1_1st_head.html#ac6d06c75ea6ae12bcab635e1a2b8b7c1">m_count</a>;     <span class="comment">// 本层数据数量</span></div>
<div class="line"><a id="l00031" name="l00031"></a><span class="lineno"><a class="line" href="../../de/d7b/structskip_list_1_1st_head.html#a66aa39934111e57bead64c6460068a7d">   31</a></span>        std::shared_ptr&lt; stNode &gt;     <a class="code hl_variable" href="../../de/d7b/structskip_list_1_1st_head.html#a66aa39934111e57bead64c6460068a7d">pt_data</a>;     <span class="comment">// 数据头</span></div>
<div class="line"><a id="l00032" name="l00032"></a><span class="lineno">   32</span>        </div>
<div class="line"><a id="l00033" name="l00033"></a><span class="lineno"><a class="line" href="../../de/d7b/structskip_list_1_1st_head.html#a4b4f17a145ed2fe4d17bd377538f4b8c">   33</a></span>        <a class="code hl_function" href="../../de/d7b/structskip_list_1_1st_head.html#a4b4f17a145ed2fe4d17bd377538f4b8c">stHead</a>():<a class="code hl_variable" href="../../de/d7b/structskip_list_1_1st_head.html#ac6d06c75ea6ae12bcab635e1a2b8b7c1">m_count</a>(0){}</div>
<div class="line"><a id="l00034" name="l00034"></a><span class="lineno">   34</span>    };</div>
</div>
<div class="line"><a id="l00035" name="l00035"></a><span class="lineno">   35</span>    </div>
<div class="foldopen" id="foldopen00036" data-start="{" data-end="};">
<div class="line"><a id="l00036" name="l00036"></a><span class="lineno"><a class="line" href="../../d6/dfb/classskip_list_1_1st_iterator.html">   36</a></span>    <span class="keyword">class </span><a class="code hl_class" href="../../d6/dfb/classskip_list_1_1st_iterator.html">stIterator</a> : <span class="keyword">public</span> std::iterator&lt; bidirectional_iterator_tag &gt;{</div>
<div class="line"><a id="l00037" name="l00037"></a><span class="lineno">   37</span>    <span class="keyword">private</span>:</div>
<div class="line"><a id="l00038" name="l00038"></a><span class="lineno">   38</span>        <a class="code hl_struct" href="../../d6/d1d/structskip_list_1_1st_node.html">stNode</a> * p_node__;</div>
<div class="line"><a id="l00039" name="l00039"></a><span class="lineno">   39</span>    <span class="keyword">public</span>:</div>
<div class="line"><a id="l00040" name="l00040"></a><span class="lineno"><a class="line" href="../../d6/dfb/classskip_list_1_1st_iterator.html#a44788c379ee47116bbdb071a61f9c538">   40</a></span>        <a class="code hl_function" href="../../d6/dfb/classskip_list_1_1st_iterator.html#a44788c379ee47116bbdb071a61f9c538">stIterator</a>():p_node__( nullptr ){}</div>
<div class="line"><a id="l00041" name="l00041"></a><span class="lineno"><a class="line" href="../../d6/dfb/classskip_list_1_1st_iterator.html#af560a14b43fb45e7aa4de29519eddc88">   41</a></span>        <a class="code hl_function" href="../../d6/dfb/classskip_list_1_1st_iterator.html#af560a14b43fb45e7aa4de29519eddc88">stIterator</a>( <a class="code hl_struct" href="../../d6/d1d/structskip_list_1_1st_node.html">stNode</a> * node ):p_node__( node ){}</div>
<div class="line"><a id="l00042" name="l00042"></a><span class="lineno">   42</span>    }</div>
</div>
<div class="line"><a id="l00043" name="l00043"></a><span class="lineno">   43</span>    </div>
<div class="line"><a id="l00044" name="l00044"></a><span class="lineno"><a class="line" href="../../d7/d37/classskip_list.html#a0ff611f763f2a2676849d226a8fc4f09">   44</a></span>    <span class="keyword">using </span><a class="code hl_variable" href="../../d7/d37/classskip_list.html#a0ff611f763f2a2676849d226a8fc4f09">iterator</a> = <a class="code hl_class" href="../../d6/dfb/classskip_list_1_1st_iterator.html">stIterator</a>;</div>
<div class="line"><a id="l00045" name="l00045"></a><span class="lineno">   45</span><span class="keyword">protected</span>:</div>
<div class="line"><a id="l00046" name="l00046"></a><span class="lineno"><a class="line" href="../../d7/d37/classskip_list.html#a37b362a7ba62c11779885c0ecfd85c88">   46</a></span>    std::vector&lt; stHead &gt;     <a class="code hl_variable" href="../../d7/d37/classskip_list.html#a37b362a7ba62c11779885c0ecfd85c88">m_head__</a>;</div>
<div class="line"><a id="l00047" name="l00047"></a><span class="lineno"><a class="line" href="../../d7/d37/classskip_list.html#a193a38d21fb42c2ba27975940d7e121e">   47</a></span>    std::mutex                <a class="code hl_variable" href="../../d7/d37/classskip_list.html#a193a38d21fb42c2ba27975940d7e121e">m_mutex__</a>;</div>
<div class="line"><a id="l00048" name="l00048"></a><span class="lineno">   48</span><span class="keyword">protected</span>:</div>
<div class="foldopen" id="foldopen00053" data-start="{" data-end="}">
<div class="line"><a id="l00053" name="l00053"></a><span class="lineno"><a class="line" href="../../d7/d37/classskip_list.html#a3e7bd12244eedd27ff7309bc4d38f021">   53</a></span>    <span class="keywordtype">size_t</span> <a class="code hl_function" href="../../d7/d37/classskip_list.html#a3e7bd12244eedd27ff7309bc4d38f021">level_count__</a>( <span class="keywordtype">size_t</span> nodeCount ){</div>
<div class="line"><a id="l00054" name="l00054"></a><span class="lineno">   54</span>        <span class="keywordtype">size_t</span> ret = 0; c = nodeCount;</div>
<div class="line"><a id="l00055" name="l00055"></a><span class="lineno">   55</span>        <span class="keywordflow">for</span>( ;; ret ++ ){</div>
<div class="line"><a id="l00056" name="l00056"></a><span class="lineno">   56</span>            c &gt;&gt;= 1;</div>
<div class="line"><a id="l00057" name="l00057"></a><span class="lineno">   57</span>            <span class="keywordflow">if</span>( c &lt;= 3 &amp;&amp; c &gt; 1 ){</div>
<div class="line"><a id="l00058" name="l00058"></a><span class="lineno">   58</span>                <span class="keywordflow">break</span>;</div>
<div class="line"><a id="l00059" name="l00059"></a><span class="lineno">   59</span>            }</div>
<div class="line"><a id="l00060" name="l00060"></a><span class="lineno">   60</span>        }</div>
<div class="line"><a id="l00061" name="l00061"></a><span class="lineno">   61</span>        </div>
<div class="line"><a id="l00062" name="l00062"></a><span class="lineno">   62</span>        <span class="keywordflow">return</span> ret;</div>
<div class="line"><a id="l00063" name="l00063"></a><span class="lineno">   63</span>    }</div>
</div>
<div class="line"><a id="l00064" name="l00064"></a><span class="lineno">   64</span><span class="keyword">public</span>:</div>
<div class="line"><a id="l00065" name="l00065"></a><span class="lineno"><a class="line" href="../../d7/d37/classskip_list.html#a41ad3b730190195d6740ccf07d8df7d0">   65</a></span>    <a class="code hl_function" href="../../d7/d37/classskip_list.html#a41ad3b730190195d6740ccf07d8df7d0">skipList</a>(){}</div>
<div class="foldopen" id="foldopen00066" data-start="{" data-end="}">
<div class="line"><a id="l00066" name="l00066"></a><span class="lineno"><a class="line" href="../../d7/d37/classskip_list.html#a6c8592ea4d95ec292395c132e8ff7192">   66</a></span>    <a class="code hl_function" href="../../d7/d37/classskip_list.html#a6c8592ea4d95ec292395c132e8ff7192">skipList</a>( <span class="keywordtype">size_t</span> s ): <a class="code hl_variable" href="../../d7/d37/classskip_list.html#a37b362a7ba62c11779885c0ecfd85c88">m_head__</a>( s ){</div>
<div class="line"><a id="l00067" name="l00067"></a><span class="lineno">   67</span>        </div>
<div class="line"><a id="l00068" name="l00068"></a><span class="lineno">   68</span>    }</div>
</div>
<div class="line"><a id="l00069" name="l00069"></a><span class="lineno"><a class="line" href="../../d7/d37/classskip_list.html#a49ea58b52162713cd0ba30f3e2f40717">   69</a></span>    <span class="keyword">virtual</span> <a class="code hl_function" href="../../d7/d37/classskip_list.html#a49ea58b52162713cd0ba30f3e2f40717">~skipList</a>(){}</div>
<div class="foldopen" id="foldopen00074" data-start="{" data-end="}">
<div class="line"><a id="l00074" name="l00074"></a><span class="lineno"><a class="line" href="../../d7/d37/classskip_list.html#a3fc93f8da0649624d63dc0e8d93838d2">   74</a></span>    <span class="keywordtype">bool</span> <a class="code hl_function" href="../../d7/d37/classskip_list.html#a3fc93f8da0649624d63dc0e8d93838d2">insert</a>( <span class="keyword">const</span> <a class="code hl_typedef" href="../../d7/d37/classskip_list.html#ab04a8617aa95c59b6823c4a7f90c4d60">value_type</a>&amp; data ){</div>
<div class="line"><a id="l00075" name="l00075"></a><span class="lineno">   75</span>        <span class="keywordtype">bool</span> ret = <span class="keyword">false</span>;</div>
<div class="line"><a id="l00076" name="l00076"></a><span class="lineno">   76</span>        <span class="keywordtype">size_t</span> cl = <a class="code hl_variable" href="../../d7/d37/classskip_list.html#a37b362a7ba62c11779885c0ecfd85c88">m_head__</a>.size() , new_level = <a class="code hl_function" href="../../d7/d37/classskip_list.html#a3e7bd12244eedd27ff7309bc4d38f021">level_count__</a>( <a class="code hl_variable" href="../../d7/d37/classskip_list.html#a37b362a7ba62c11779885c0ecfd85c88">m_head__</a>[ 0 ].m_count + 1 );</div>
<div class="line"><a id="l00077" name="l00077"></a><span class="lineno">   77</span>        <span class="keywordflow">if</span>( new_level &gt; c1 ){</div>
<div class="line"><a id="l00078" name="l00078"></a><span class="lineno">   78</span>            <a class="code hl_variable" href="../../d7/d37/classskip_list.html#a37b362a7ba62c11779885c0ecfd85c88">m_head__</a>.push_back( <a class="code hl_struct" href="../../de/d7b/structskip_list_1_1st_head.html">stHead</a> );</div>
<div class="line"><a id="l00079" name="l00079"></a><span class="lineno">   79</span>        }<span class="keywordflow">else</span>{</div>
<div class="line"><a id="l00080" name="l00080"></a><span class="lineno">   80</span>            </div>
<div class="line"><a id="l00081" name="l00081"></a><span class="lineno">   81</span>        }</div>
<div class="line"><a id="l00082" name="l00082"></a><span class="lineno">   82</span>        </div>
<div class="line"><a id="l00083" name="l00083"></a><span class="lineno">   83</span>        <span class="keywordflow">return</span> ret;</div>
<div class="line"><a id="l00084" name="l00084"></a><span class="lineno">   84</span>    }</div>
</div>
<div class="line"><a id="l00085" name="l00085"></a><span class="lineno">   85</span>    </div>
<div class="foldopen" id="foldopen00086" data-start="{" data-end="}">
<div class="line"><a id="l00086" name="l00086"></a><span class="lineno"><a class="line" href="../../d7/d37/classskip_list.html#ac737de735ae47caa72967a8d6cd04d23">   86</a></span>    <span class="keywordtype">void</span> <a class="code hl_function" href="../../d7/d37/classskip_list.html#ac737de735ae47caa72967a8d6cd04d23">erase</a>( <a class="code hl_variable" href="../../d7/d37/classskip_list.html#a0ff611f763f2a2676849d226a8fc4f09">iterator</a> it ){</div>
<div class="line"><a id="l00087" name="l00087"></a><span class="lineno">   87</span>        </div>
<div class="line"><a id="l00088" name="l00088"></a><span class="lineno">   88</span>    }</div>
</div>
<div class="line"><a id="l00089" name="l00089"></a><span class="lineno">   89</span>    </div>
<div class="foldopen" id="foldopen00090" data-start="{" data-end="}">
<div class="line"><a id="l00090" name="l00090"></a><span class="lineno"><a class="line" href="../../d7/d37/classskip_list.html#a669a513bb1b18c122bb4232cd739299b">   90</a></span>    <span class="keywordtype">void</span> <a class="code hl_function" href="../../d7/d37/classskip_list.html#a669a513bb1b18c122bb4232cd739299b">erase</a>( <a class="code hl_variable" href="../../d7/d37/classskip_list.html#a0ff611f763f2a2676849d226a8fc4f09">iterator</a> start , <a class="code hl_variable" href="../../d7/d37/classskip_list.html#a0ff611f763f2a2676849d226a8fc4f09">iterator</a> end ){</div>
<div class="line"><a id="l00091" name="l00091"></a><span class="lineno">   91</span>        </div>
<div class="line"><a id="l00092" name="l00092"></a><span class="lineno">   92</span>    }</div>
</div>
<div class="line"><a id="l00096" name="l00096"></a><span class="lineno">   96</span>    <span class="keyword">template</span>&lt; <span class="keyword">typename</span> KEY_TYPE &gt;</div>
<div class="foldopen" id="foldopen00097" data-start="{" data-end="}">
<div class="line"><a id="l00097" name="l00097"></a><span class="lineno"><a class="line" href="../../d7/d37/classskip_list.html#aaeb93ff971830b6f00276c0757da13ed">   97</a></span>    <a class="code hl_variable" href="../../d7/d37/classskip_list.html#a0ff611f763f2a2676849d226a8fc4f09">iterator</a> <a class="code hl_function" href="../../d7/d37/classskip_list.html#aaeb93ff971830b6f00276c0757da13ed">find_if</a>( KEY_TYPE&amp;&amp; key , std::function&lt; <span class="keywordtype">int</span> ( KEY_TYPE&amp;&amp; , <span class="keyword">const</span> <a class="code hl_typedef" href="../../d7/d37/classskip_list.html#ab04a8617aa95c59b6823c4a7f90c4d60">value_type</a>&amp; ) &gt; compare ){</div>
<div class="line"><a id="l00098" name="l00098"></a><span class="lineno">   98</span>        <span class="keywordtype">size_t</span> cl = <a class="code hl_variable" href="../../d7/d37/classskip_list.html#a37b362a7ba62c11779885c0ecfd85c88">m_head__</a>.size() - 1;</div>
<div class="line"><a id="l00099" name="l00099"></a><span class="lineno">   99</span>        <span class="keywordflow">if</span>( cl == 0 ) <span class="keywordflow">return</span> <a class="code hl_variable" href="../../d7/d37/classskip_list.html#a0ff611f763f2a2676849d226a8fc4f09">iterator</a>(<span class="keyword">nullptr</span>);</div>
<div class="line"><a id="l00100" name="l00100"></a><span class="lineno">  100</span>        <a class="code hl_variable" href="../../d7/d37/classskip_list.html#a0ff611f763f2a2676849d226a8fc4f09">iterator</a> ret;</div>
<div class="line"><a id="l00101" name="l00101"></a><span class="lineno">  101</span>        <span class="comment">// 从第一层开始找</span></div>
<div class="line"><a id="l00102" name="l00102"></a><span class="lineno">  102</span>        <a class="code hl_struct" href="../../d6/d1d/structskip_list_1_1st_node.html">stNode</a> * p_node = <a class="code hl_variable" href="../../d7/d37/classskip_list.html#a37b362a7ba62c11779885c0ecfd85c88">m_head__</a>[ cl ].pt_data.get();</div>
<div class="line"><a id="l00103" name="l00103"></a><span class="lineno">  103</span>        <span class="keywordflow">while</span>( p_node ){</div>
<div class="line"><a id="l00104" name="l00104"></a><span class="lineno">  104</span>            <span class="comment">// 找到数据，则将指针移动到最后一层。使用这一层的数据作为实际返回的内容</span></div>
<div class="line"><a id="l00105" name="l00105"></a><span class="lineno">  105</span>            <span class="keywordflow">if</span>( compare( std::forward&lt; KEY_TYPE &gt;( key ) ,  p_node-&gt;<a class="code hl_variable" href="../../d6/d1d/structskip_list_1_1st_node.html#aeab4d54bbcfd42dcf9797573f280d2c0">m_value</a> ) == 0 ){</div>
<div class="line"><a id="l00106" name="l00106"></a><span class="lineno">  106</span>                <span class="keywordflow">while</span>( p_node-&gt;p_down ){</div>
<div class="line"><a id="l00107" name="l00107"></a><span class="lineno">  107</span>                    p_node = p_node-&gt;p_down.get();</div>
<div class="line"><a id="l00108" name="l00108"></a><span class="lineno">  108</span>                }</div>
<div class="line"><a id="l00109" name="l00109"></a><span class="lineno">  109</span>                </div>
<div class="line"><a id="l00110" name="l00110"></a><span class="lineno">  110</span>                ret.set( p_node );</div>
<div class="line"><a id="l00111" name="l00111"></a><span class="lineno">  111</span>                <span class="keywordflow">break</span>;</div>
<div class="line"><a id="l00112" name="l00112"></a><span class="lineno">  112</span>            }<span class="keywordflow">else</span> <span class="keywordflow">if</span>( compare( std::forward&lt; KEY_TYPE &gt;( key ) ,  p_node-&gt;<a class="code hl_variable" href="../../d6/d1d/structskip_list_1_1st_node.html#aeab4d54bbcfd42dcf9797573f280d2c0">m_value</a> ) &lt; 0 ){ </div>
<div class="line"><a id="l00113" name="l00113"></a><span class="lineno">  113</span>                cl --;</div>
<div class="line"><a id="l00114" name="l00114"></a><span class="lineno">  114</span>                <span class="keywordflow">if</span>( cl &lt; 0 ){ <span class="keywordflow">return</span> ret; }</div>
<div class="line"><a id="l00115" name="l00115"></a><span class="lineno">  115</span>                <span class="keywordflow">if</span>( p_node = p_node-&gt;p_pre ){   </div>
<div class="line"><a id="l00116" name="l00116"></a><span class="lineno">  116</span>                    p_node = p_node-&gt;p_pre-&gt;p_down.get();</div>
<div class="line"><a id="l00117" name="l00117"></a><span class="lineno">  117</span>                }<span class="keywordflow">else</span>{</div>
<div class="line"><a id="l00118" name="l00118"></a><span class="lineno">  118</span>                    p_node = <a class="code hl_variable" href="../../d7/d37/classskip_list.html#a37b362a7ba62c11779885c0ecfd85c88">m_head__</a>[ c1 ].pt_data.get();</div>
<div class="line"><a id="l00119" name="l00119"></a><span class="lineno">  119</span>                }</div>
<div class="line"><a id="l00120" name="l00120"></a><span class="lineno">  120</span>            }<span class="keywordflow">else</span>{</div>
<div class="line"><a id="l00121" name="l00121"></a><span class="lineno">  121</span>                p_node = p_node-&gt;p_next.get();</div>
<div class="line"><a id="l00122" name="l00122"></a><span class="lineno">  122</span>            }</div>
<div class="line"><a id="l00123" name="l00123"></a><span class="lineno">  123</span>        }</div>
<div class="line"><a id="l00124" name="l00124"></a><span class="lineno">  124</span>    }</div>
</div>
<div class="foldopen" id="foldopen00129" data-start="{" data-end="}">
<div class="line"><a id="l00129" name="l00129"></a><span class="lineno"><a class="line" href="../../d7/d37/classskip_list.html#a49005577a3c9f48462bc6d03d8646d92">  129</a></span>    <a class="code hl_variable" href="../../d7/d37/classskip_list.html#a0ff611f763f2a2676849d226a8fc4f09">iterator</a> <a class="code hl_function" href="../../d7/d37/classskip_list.html#a49005577a3c9f48462bc6d03d8646d92">find</a>( <span class="keyword">const</span> <a class="code hl_typedef" href="../../d7/d37/classskip_list.html#ab04a8617aa95c59b6823c4a7f90c4d60">value_type</a>&amp; data ){</div>
<div class="line"><a id="l00130" name="l00130"></a><span class="lineno">  130</span>        <span class="keywordtype">size_t</span> cl = <a class="code hl_variable" href="../../d7/d37/classskip_list.html#a37b362a7ba62c11779885c0ecfd85c88">m_head__</a>.size() - 1;</div>
<div class="line"><a id="l00131" name="l00131"></a><span class="lineno">  131</span>        <span class="keywordflow">if</span>( cl == 0 ) <span class="keywordflow">return</span> <a class="code hl_variable" href="../../d7/d37/classskip_list.html#a0ff611f763f2a2676849d226a8fc4f09">iterator</a>(<span class="keyword">nullptr</span>);</div>
<div class="line"><a id="l00132" name="l00132"></a><span class="lineno">  132</span>        <a class="code hl_variable" href="../../d7/d37/classskip_list.html#a0ff611f763f2a2676849d226a8fc4f09">iterator</a> ret;</div>
<div class="line"><a id="l00133" name="l00133"></a><span class="lineno">  133</span>        <span class="comment">// 从第一层开始找</span></div>
<div class="line"><a id="l00134" name="l00134"></a><span class="lineno">  134</span>        <a class="code hl_struct" href="../../d6/d1d/structskip_list_1_1st_node.html">stNode</a> * p_node = <a class="code hl_variable" href="../../d7/d37/classskip_list.html#a37b362a7ba62c11779885c0ecfd85c88">m_head__</a>[ cl ].pt_data.get();</div>
<div class="line"><a id="l00135" name="l00135"></a><span class="lineno">  135</span>        <span class="keywordflow">while</span>( p_node ){</div>
<div class="line"><a id="l00136" name="l00136"></a><span class="lineno">  136</span>            <span class="comment">// 找到数据，则将指针移动到最后一层。使用这一层的数据作为实际返回的内容</span></div>
<div class="line"><a id="l00137" name="l00137"></a><span class="lineno">  137</span>            <span class="keywordflow">if</span>( p_node-&gt;<a class="code hl_variable" href="../../d6/d1d/structskip_list_1_1st_node.html#aeab4d54bbcfd42dcf9797573f280d2c0">m_value</a> == data ){</div>
<div class="line"><a id="l00138" name="l00138"></a><span class="lineno">  138</span>                <span class="keywordflow">while</span>( p_node-&gt;p_down ){</div>
<div class="line"><a id="l00139" name="l00139"></a><span class="lineno">  139</span>                    p_node = p_node-&gt;p_down.get();</div>
<div class="line"><a id="l00140" name="l00140"></a><span class="lineno">  140</span>                }</div>
<div class="line"><a id="l00141" name="l00141"></a><span class="lineno">  141</span>                </div>
<div class="line"><a id="l00142" name="l00142"></a><span class="lineno">  142</span>                ret.set( p_node );</div>
<div class="line"><a id="l00143" name="l00143"></a><span class="lineno">  143</span>                <span class="keywordflow">break</span>;</div>
<div class="line"><a id="l00144" name="l00144"></a><span class="lineno">  144</span>            }<span class="keywordflow">else</span> <span class="keywordflow">if</span>( p_node-&gt;<a class="code hl_variable" href="../../d6/d1d/structskip_list_1_1st_node.html#aeab4d54bbcfd42dcf9797573f280d2c0">m_value</a> &lt; data ){ </div>
<div class="line"><a id="l00145" name="l00145"></a><span class="lineno">  145</span>                cl --;</div>
<div class="line"><a id="l00146" name="l00146"></a><span class="lineno">  146</span>                <span class="keywordflow">if</span>( cl &lt; 0 ){</div>
<div class="line"><a id="l00147" name="l00147"></a><span class="lineno">  147</span>                    <span class="keywordflow">return</span> ret;</div>
<div class="line"><a id="l00148" name="l00148"></a><span class="lineno">  148</span>                }</div>
<div class="line"><a id="l00149" name="l00149"></a><span class="lineno">  149</span>                <span class="keywordflow">if</span>( p_node = p_node-&gt;p_pre ){   </div>
<div class="line"><a id="l00150" name="l00150"></a><span class="lineno">  150</span>                    p_node = p_node-&gt;p_pre-&gt;p_down.get();</div>
<div class="line"><a id="l00151" name="l00151"></a><span class="lineno">  151</span>                }<span class="keywordflow">else</span>{</div>
<div class="line"><a id="l00152" name="l00152"></a><span class="lineno">  152</span>                    p_node = <a class="code hl_variable" href="../../d7/d37/classskip_list.html#a37b362a7ba62c11779885c0ecfd85c88">m_head__</a>[ c1 ].pt_data.get();</div>
<div class="line"><a id="l00153" name="l00153"></a><span class="lineno">  153</span>                }</div>
<div class="line"><a id="l00154" name="l00154"></a><span class="lineno">  154</span>            }<span class="keywordflow">else</span>{</div>
<div class="line"><a id="l00155" name="l00155"></a><span class="lineno">  155</span>                p_node = p_node-&gt;p_next.get();</div>
<div class="line"><a id="l00156" name="l00156"></a><span class="lineno">  156</span>            }</div>
<div class="line"><a id="l00157" name="l00157"></a><span class="lineno">  157</span>        }</div>
<div class="line"><a id="l00158" name="l00158"></a><span class="lineno">  158</span>        </div>
<div class="line"><a id="l00159" name="l00159"></a><span class="lineno">  159</span>        <span class="keywordflow">return</span> ret;</div>
<div class="line"><a id="l00160" name="l00160"></a><span class="lineno">  160</span>    }</div>
</div>
<div class="line"><a id="l00161" name="l00161"></a><span class="lineno">  161</span>    </div>
<div class="line"><a id="l00162" name="l00162"></a><span class="lineno">  162</span>    </div>
<div class="line"><a id="l00163" name="l00163"></a><span class="lineno">  163</span>};</div>
</div>
<div class="ttc" id="aclassskip_list_1_1st_iterator_html"><div class="ttname"><a href="../../d6/dfb/classskip_list_1_1st_iterator.html">skipList::stIterator</a></div><div class="ttdef"><b>定义</b> <a href="#l00036">skipList.hpp:36</a></div></div>
<div class="ttc" id="aclassskip_list_1_1st_iterator_html_a44788c379ee47116bbdb071a61f9c538"><div class="ttname"><a href="../../d6/dfb/classskip_list_1_1st_iterator.html#a44788c379ee47116bbdb071a61f9c538">skipList::stIterator::stIterator</a></div><div class="ttdeci">stIterator()</div><div class="ttdef"><b>定义</b> <a href="#l00040">skipList.hpp:40</a></div></div>
<div class="ttc" id="aclassskip_list_1_1st_iterator_html_af560a14b43fb45e7aa4de29519eddc88"><div class="ttname"><a href="../../d6/dfb/classskip_list_1_1st_iterator.html#af560a14b43fb45e7aa4de29519eddc88">skipList::stIterator::stIterator</a></div><div class="ttdeci">stIterator(stNode *node)</div><div class="ttdef"><b>定义</b> <a href="#l00041">skipList.hpp:41</a></div></div>
<div class="ttc" id="aclassskip_list_html"><div class="ttname"><a href="../../d7/d37/classskip_list.html">skipList</a></div><div class="ttdoc">跳表的实现</div><div class="ttdef"><b>定义</b> <a href="#l00017">skipList.hpp:18</a></div></div>
<div class="ttc" id="aclassskip_list_html_a0ff611f763f2a2676849d226a8fc4f09"><div class="ttname"><a href="../../d7/d37/classskip_list.html#a0ff611f763f2a2676849d226a8fc4f09">skipList::iterator</a></div><div class="ttdeci">skipList::stIterator iterator</div></div>
<div class="ttc" id="aclassskip_list_html_a193a38d21fb42c2ba27975940d7e121e"><div class="ttname"><a href="../../d7/d37/classskip_list.html#a193a38d21fb42c2ba27975940d7e121e">skipList::m_mutex__</a></div><div class="ttdeci">std::mutex m_mutex__</div><div class="ttdef"><b>定义</b> <a href="#l00047">skipList.hpp:47</a></div></div>
<div class="ttc" id="aclassskip_list_html_a37b362a7ba62c11779885c0ecfd85c88"><div class="ttname"><a href="../../d7/d37/classskip_list.html#a37b362a7ba62c11779885c0ecfd85c88">skipList::m_head__</a></div><div class="ttdeci">std::vector&lt; stHead &gt; m_head__</div><div class="ttdef"><b>定义</b> <a href="#l00046">skipList.hpp:46</a></div></div>
<div class="ttc" id="aclassskip_list_html_a3e7bd12244eedd27ff7309bc4d38f021"><div class="ttname"><a href="../../d7/d37/classskip_list.html#a3e7bd12244eedd27ff7309bc4d38f021">skipList::level_count__</a></div><div class="ttdeci">size_t level_count__(size_t nodeCount)</div><div class="ttdoc">计算层数</div><div class="ttdef"><b>定义</b> <a href="#l00053">skipList.hpp:53</a></div></div>
<div class="ttc" id="aclassskip_list_html_a3fc93f8da0649624d63dc0e8d93838d2"><div class="ttname"><a href="../../d7/d37/classskip_list.html#a3fc93f8da0649624d63dc0e8d93838d2">skipList::insert</a></div><div class="ttdeci">bool insert(const value_type &amp;data)</div><div class="ttdoc">插入节点</div><div class="ttdef"><b>定义</b> <a href="#l00074">skipList.hpp:74</a></div></div>
<div class="ttc" id="aclassskip_list_html_a41ad3b730190195d6740ccf07d8df7d0"><div class="ttname"><a href="../../d7/d37/classskip_list.html#a41ad3b730190195d6740ccf07d8df7d0">skipList::skipList</a></div><div class="ttdeci">skipList()</div><div class="ttdef"><b>定义</b> <a href="#l00065">skipList.hpp:65</a></div></div>
<div class="ttc" id="aclassskip_list_html_a49005577a3c9f48462bc6d03d8646d92"><div class="ttname"><a href="../../d7/d37/classskip_list.html#a49005577a3c9f48462bc6d03d8646d92">skipList::find</a></div><div class="ttdeci">iterator find(const value_type &amp;data)</div><div class="ttdef"><b>定义</b> <a href="#l00129">skipList.hpp:129</a></div></div>
<div class="ttc" id="aclassskip_list_html_a49ea58b52162713cd0ba30f3e2f40717"><div class="ttname"><a href="../../d7/d37/classskip_list.html#a49ea58b52162713cd0ba30f3e2f40717">skipList::~skipList</a></div><div class="ttdeci">virtual ~skipList()</div><div class="ttdef"><b>定义</b> <a href="#l00069">skipList.hpp:69</a></div></div>
<div class="ttc" id="aclassskip_list_html_a669a513bb1b18c122bb4232cd739299b"><div class="ttname"><a href="../../d7/d37/classskip_list.html#a669a513bb1b18c122bb4232cd739299b">skipList::erase</a></div><div class="ttdeci">void erase(iterator start, iterator end)</div><div class="ttdef"><b>定义</b> <a href="#l00090">skipList.hpp:90</a></div></div>
<div class="ttc" id="aclassskip_list_html_a6c8592ea4d95ec292395c132e8ff7192"><div class="ttname"><a href="../../d7/d37/classskip_list.html#a6c8592ea4d95ec292395c132e8ff7192">skipList::skipList</a></div><div class="ttdeci">skipList(size_t s)</div><div class="ttdef"><b>定义</b> <a href="#l00066">skipList.hpp:66</a></div></div>
<div class="ttc" id="aclassskip_list_html_aaeb93ff971830b6f00276c0757da13ed"><div class="ttname"><a href="../../d7/d37/classskip_list.html#aaeb93ff971830b6f00276c0757da13ed">skipList::find_if</a></div><div class="ttdeci">iterator find_if(KEY_TYPE &amp;&amp;key, std::function&lt; int(KEY_TYPE &amp;&amp;, const value_type &amp;) &gt; compare)</div><div class="ttdef"><b>定义</b> <a href="#l00097">skipList.hpp:97</a></div></div>
<div class="ttc" id="aclassskip_list_html_ab04a8617aa95c59b6823c4a7f90c4d60"><div class="ttname"><a href="../../d7/d37/classskip_list.html#ab04a8617aa95c59b6823c4a7f90c4d60">skipList::value_type</a></div><div class="ttdeci">typename std::remove_pointer&lt; typename std::decay&lt; T &gt; ::type &gt;::type value_type</div><div class="ttdef"><b>定义</b> <a href="#l00020">skipList.hpp:20</a></div></div>
<div class="ttc" id="aclassskip_list_html_ac737de735ae47caa72967a8d6cd04d23"><div class="ttname"><a href="../../d7/d37/classskip_list.html#ac737de735ae47caa72967a8d6cd04d23">skipList::erase</a></div><div class="ttdeci">void erase(iterator it)</div><div class="ttdef"><b>定义</b> <a href="#l00086">skipList.hpp:86</a></div></div>
<div class="ttc" id="astructskip_list_1_1st_head_html"><div class="ttname"><a href="../../de/d7b/structskip_list_1_1st_head.html">skipList::stHead</a></div><div class="ttdef"><b>定义</b> <a href="#l00029">skipList.hpp:29</a></div></div>
<div class="ttc" id="astructskip_list_1_1st_head_html_a4b4f17a145ed2fe4d17bd377538f4b8c"><div class="ttname"><a href="../../de/d7b/structskip_list_1_1st_head.html#a4b4f17a145ed2fe4d17bd377538f4b8c">skipList::stHead::stHead</a></div><div class="ttdeci">stHead()</div><div class="ttdef"><b>定义</b> <a href="#l00033">skipList.hpp:33</a></div></div>
<div class="ttc" id="astructskip_list_1_1st_head_html_a66aa39934111e57bead64c6460068a7d"><div class="ttname"><a href="../../de/d7b/structskip_list_1_1st_head.html#a66aa39934111e57bead64c6460068a7d">skipList::stHead::pt_data</a></div><div class="ttdeci">std::shared_ptr&lt; stNode &gt; pt_data</div><div class="ttdef"><b>定义</b> <a href="#l00031">skipList.hpp:31</a></div></div>
<div class="ttc" id="astructskip_list_1_1st_head_html_ac6d06c75ea6ae12bcab635e1a2b8b7c1"><div class="ttname"><a href="../../de/d7b/structskip_list_1_1st_head.html#ac6d06c75ea6ae12bcab635e1a2b8b7c1">skipList::stHead::m_count</a></div><div class="ttdeci">size_t m_count</div><div class="ttdef"><b>定义</b> <a href="#l00030">skipList.hpp:30</a></div></div>
<div class="ttc" id="astructskip_list_1_1st_node_html"><div class="ttname"><a href="../../d6/d1d/structskip_list_1_1st_node.html">skipList::stNode</a></div><div class="ttdef"><b>定义</b> <a href="#l00022">skipList.hpp:22</a></div></div>
<div class="ttc" id="astructskip_list_1_1st_node_html_a2541341e5aaeed692acae459554700f9"><div class="ttname"><a href="../../d6/d1d/structskip_list_1_1st_node.html#a2541341e5aaeed692acae459554700f9">skipList::stNode::pt_pre</a></div><div class="ttdeci">std::shared_ptr&lt; stNode &gt; pt_pre</div><div class="ttdef"><b>定义</b> <a href="#l00025">skipList.hpp:25</a></div></div>
<div class="ttc" id="astructskip_list_1_1st_node_html_a26cc314106ff74169938ed021c555fe1"><div class="ttname"><a href="../../d6/d1d/structskip_list_1_1st_node.html#a26cc314106ff74169938ed021c555fe1">skipList::stNode::pt_down</a></div><div class="ttdeci">std::shared_ptr&lt; stNode &gt; pt_down</div><div class="ttdef"><b>定义</b> <a href="#l00026">skipList.hpp:26</a></div></div>
<div class="ttc" id="astructskip_list_1_1st_node_html_ad026941f387c6246bb4d2839199d8f7b"><div class="ttname"><a href="../../d6/d1d/structskip_list_1_1st_node.html#ad026941f387c6246bb4d2839199d8f7b">skipList::stNode::pt_next</a></div><div class="ttdeci">std::shared_ptr&lt; stNode &gt; pt_next</div><div class="ttdef"><b>定义</b> <a href="#l00024">skipList.hpp:24</a></div></div>
<div class="ttc" id="astructskip_list_1_1st_node_html_aeab4d54bbcfd42dcf9797573f280d2c0"><div class="ttname"><a href="../../d6/d1d/structskip_list_1_1st_node.html#aeab4d54bbcfd42dcf9797573f280d2c0">skipList::stNode::m_value</a></div><div class="ttdeci">value_type m_value</div><div class="ttdef"><b>定义</b> <a href="#l00023">skipList.hpp:23</a></div></div>
</div><!-- fragment --></div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
制作者&#160;<a href="https://www.doxygen.org/index.html"><img class="footer" src="../../doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.11.0
</small></address>
</div><!-- doc-content -->
</body>
</html>
